package self.niu.com.resume.db.dao.impl;


import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.exception.DbException;

import java.util.List;

import self.niu.com.resume.AppBase;
import self.niu.com.resume.db.User;
import self.niu.com.resume.db.dao.UserDao;

/**
 * Created by Administrator on 2015/9/26.
 */
public class UserDaoImpl implements UserDao {
    public DbUtils db;

    public UserDaoImpl() {
        this.db = AppBase.db;
    }

    @Override
    public void update(User user, String numberCusor) {
        try {
            db.update(user, numberCusor);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }


    @Override
    public void save(User user) {
        try {
            db.save(user);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void deleteById(int id) {

    }

    @Override
    public User find(String name) {
        return null;
    }

    @Override
    public List<User> findAll() {
        List<User> list = null;
        try {
            list = db.findAll(User.class);
        } catch (DbException e) {
            e.printStackTrace();
        }
   /*     User u = list.get(1);
        String n = u.getContent();
        String ss = u.getId();*/
        return list;
    }

    @Override
    public void createDb(Class t) {
        try {
            db.createTableIfNotExist(t);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }
}
